#ifndef SOCKETMANAGER_H
#define SOCKETMANAGER_H

#include <string>
#include <unordered_map>
#include <mutex>

class SocketManager
{
public:
    static SocketManager* getInstacne();
    void addSocket(std::string& useroc,int socket);
    void removeSocket(std::string& useroc);
    void removeSocket(int socket);
    bool isAlive(std::string& useroc);
    int getSocket(std::string& useroc);
    void updateOC(const std::string& oldoc,const std::string& newoc);
    int operator[](const std::string& useroc);
private:
    SocketManager();
    SocketManager& operator=(const SocketManager&)=delete ;
    SocketManager(const SocketManager&)=delete ;
    static SocketManager* instance;

    std::unordered_map<std::string,int> oc_socket;
    std::unordered_map<int,std::string> socket_oc;
    std::mutex mtx;
};

#endif // SOCKETMANAGER_H
